// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;
import cMountMgr from "../SuperMgr/cMountMgr";
@ccclass
export default class jymtGameTabHelperMount extends cMountMgr {
    @property({type:cc.Node,tooltip:"复选框"})
    toggles:cc.Node[] = [];
    @property({type:cc.Node,tooltip:"规则"})
    rules:cc.Node[] = [];
    index:number = 0;
    //关闭
    onClose(){
        let mod = this.getModule(null);
        mod.changeClose();
    }
    onNext(){
        let index = ++this.index;
        this.index = index < 3 ? index : 0 ;
        this.onShow();
    }
    onLast(){
        let index = --this.index;
        this.index = index < 0 ? 2 : index ;
        this.onShow();
    }

    onCheck(...grgs:any[]){
        let v:string = grgs.pop();
        this.index = Number(v);
        this.onShow();
    }

    //更新
    onShow(){
        for(let i = 0;i < 3;i++) {
            this.rules[i].active = false;
        }
        this.rules[this.index].active = true;
        this.toggles[this.index].getComponent(cc.Toggle).isChecked = true;
    }
}
